package com.hello.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hello.common.log.annotation.Log;
import com.hello.common.log.enums.BusinessType;
import com.hello.system.domain.ShippingDetails;
import com.hello.system.service.IShippingDetailsService;
import com.hello.common.core.web.controller.BaseController;
import com.hello.common.core.web.domain.AjaxResult;
import com.hello.common.core.utils.poi.ExcelUtil;
import com.hello.common.core.web.page.TableDataInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
 * 纸质信件邮寄信息Controller
 * 
 * @author hello
 * @date 2025-05-15
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/details")
public class ShippingDetailsController extends BaseController
{
    private final IShippingDetailsService shippingDetailsService;

    /**
     * 查询纸质信件邮寄信息列表
     */
    @GetMapping("/list")
    public TableDataInfo list(ShippingDetails shippingDetails)
    {
        startPage();
        List<ShippingDetails> list = shippingDetailsService.selectShippingDetailsList(shippingDetails);
        return getDataTable(list);
    }

    /**
     * 导出纸质信件邮寄信息列表
     */
    @Log(title = "纸质信件邮寄信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShippingDetails shippingDetails)
    {
        List<ShippingDetails> list = shippingDetailsService.selectShippingDetailsList(shippingDetails);
        ExcelUtil<ShippingDetails> util = new ExcelUtil<ShippingDetails>(ShippingDetails.class);
        util.exportExcel(response, list, "纸质信件邮寄信息数据");
    }

    /**
     * 获取纸质信件邮寄信息详细信息
     */
    @GetMapping(value = "/{shippingId}")
    public AjaxResult getInfo(@PathVariable("shippingId") Long shippingId)
    {
        return success(shippingDetailsService.selectShippingDetailsByShippingId(shippingId));
    }

    /**
     * 新增纸质信件邮寄信息
     */
    @Log(title = "纸质信件邮寄信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShippingDetails shippingDetails)
    {
        return toAjax(shippingDetailsService.insertShippingDetails(shippingDetails));
    }

    /**
     * 修改纸质信件邮寄信息
     */
    @Log(title = "纸质信件邮寄信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShippingDetails shippingDetails)
    {
        return toAjax(shippingDetailsService.updateShippingDetails(shippingDetails));
    }

    /**
     * 删除纸质信件邮寄信息
     */
    @Log(title = "纸质信件邮寄信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shippingIds}")
    public AjaxResult remove(@PathVariable Long[] shippingIds)
    {
        return toAjax(shippingDetailsService.deleteShippingDetailsByShippingIds(shippingIds));
    }
}
